<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>函数参数默认值</title>
</head>
<body>
    <script>
        //ES6 允许给函数参数赋值初始值  
        //1. 参数直接设置默认值  具有默认值的参数, 位置一般要靠后(潜规则)
        function fn(a,b,d,e,c=99){
            console.log(a,b,c);
        }
        fn(1,2,3,4,5);

        //2. 与解构赋值结合使用   解构赋值的形式先后顺序不影响
        
        function connect({host='localhost',port=80,headers,body,method}){
            console.log(host,port,method,headers,body);
        }
        connect({
            host:'127.0.0.1',
            port:8080,
            body:'123123',
            headers:'cookie',
            method:'POST'
        });

    </script>
</body>
</html>